1. Field of the Invention
The present invention relates to the field of garbage collection during memory management processes and, more particularly, to low latency optimization for generational garbage collection based on dynamic nursery heap adjustment and predicted nursery garbage collections.
2. Description of the Related Art
Virtual machines such as the Java Virtual Machine (JVM) perform garbage collection using a complex set of generational garbage collection algorithms. These algorithms are tuned for best performance in most situations, but in specific situations unwanted latency can result. Garbage collection can refer to a form of memory management that reclaims garbage, or memory used by objects that will never be accessed or mutated again by an application. That is, garbage collection is an alternative to manual memory management that automatically deallocates objects to return associated memory to a system.
When garbage collection tasks are performed, system resources are consumed, which can cause a system to pause or slow down during garbage collection activities. Latency incurred by garbage collection activities can become a problem in latency sensitive situations. For example, latency sensitive protocols, such as Real Time Protocol (RTP) and Session Initiated Protocol (SIP), can experience timeouts due to garbage collection activities. These timeouts can lead to frequent retransmits, failures, and overall poor performance. Because garbage collection is an essential activity to a system, it is necessary to find a solution that does not adversely affect latency sensitive applications.
Currently, generational garbage collection is performed in manner consistent to FIG. 1 (Prior Art). In FIG. 1, a client 110 can execute a SIP capable (or any other) application 112, responsive to SIP messages. Client 110 can include memory space tenure heap 114 and nursery heap 116. Nursery heap 116 is a small area of memory where new objects are created and stored for a short period of time (e.g., one second). Consequently, nursery objects have low life expectancy. Tenure heap 114, however, is a large area of memory where objects live until they are no longer useful. Nursery garbage collector 126 can perform garbage collection several times a second when nursery heap 116 occupancy is high. When an object has survived a pre-determined amount of nursery garbage collections, it is moved to the tenure heap 114. This move from nursery heap 116 to tenure heap 114 is often referred to as promotion. The object will live in the tenure heap 114 until it is no longer needed and is garbage collected by tenure garbage collector 124. Thus, garbage collection occurs in different phases that include a nursery garbage collection phase and global phase for garbage collection. During a global phase the nursery garbage collection algorithm of collector 126 and the tenure garbage collection algorithm of collector 124 can both execute.
Timeline 140 illustrates one scenario wherein client 110 can receive SIP messages for processing and how garbage collection can affect the processing of the SIP messages. At some time during garbage collection AB, new SIP messages 142 can arrive and be queued for processing. At the end of garbage collection AB, the SIP messages 142 can be processed as shown by SIP messages processed 144. Typically, processing will trigger the client 110 to send reply SIP messages to the sender (not shown). Because SIP is a light-weight protocol, SIP messages can arrive immediately after the SIP reply messages have been sent out. As such, new SIP messages 146 illustrate the arrival of more SIP messages required to be processed. At 400 milliseconds, the nursery garbage collector 126 has begun garbage collecting the nursery 116 as shown by CD, leaving new SIP messages 146 unprocessed.
After garbage collection CD has finished, the resultant delay has caused new SIP messages 146 to be retransmitted, as shown by SIP messages retransmitted 148. This retransmission can occur frequently when garbage collection activity is high. As the retransmitted messages 148 arrive, nursery garbage collection EF begins leaving message 148 queued for processing. After garbage collection EF SIP messages 150 can be processed as shown.